import request from '@/utils/request';
import type { UserInfo, LoginRequest, LoginResponse, RegisterRequest } from './types';

export const login = (data: LoginRequest) => {
  return request<LoginResponse>({
    url: '/auth/user/login',
    method: 'post',
    data
  });
};

export const register = (data: RegisterRequest) => {
  return request<LoginResponse>({
    url: '/auth/user/register',
    method: 'post',
    data
  });
};

export const getUserInfo = () => {
  return request<{ data: UserInfo }>({
    url: '/auth/user-info',
    method: 'get'
  });
};

export const logout = () => {
  return request({
    url: '/auth/logout',
    method: 'post'
  });
}; 